<template>
  <div>
    <el-date-picker
      :picker-options="pickerOptions"
      v-model="daterange"
      type="daterange"
      format="yyyy-MM-dd"
      value-format="yyyy-MM-dd"
      range-separator="~"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
    ></el-date-picker>
    <el-button @click="qingchu">qin</el-button>
    <div>
      <el-date-picker
        v-model="value1"
        type="date"
        placeholder="选择日期"
        :picker-options="pickerOptions1">
      </el-date-picker>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      daterange: "",
      pickerMinDate: "", // 第一次选中的时间
      pickerOptions: {
        onPick: (obj) => {
          console.log("obj", obj); // {maxDate: xxx, minDate: xxx(中国标准时间)}
          this.pickerMinDate = new Date(obj.minDate).getTime();
        },
        disabledDate: (time) => {
          if (this.pickerMinDate) {
            const day1 = 4 * 24 * 3600 * 1000; // 可选的时间范围不超过7天
            let maxTime = this.pickerMinDate + day1;
            let minTime = this.pickerMinDate;
            console.log(
              "return",
              time.getTime() > maxTime || time.getTime() < minTime
            ); // 输出查看布尔值
            return time.getTime() > maxTime || time.getTime() < minTime;
          }
        },
      }, 
      value: "",

      pickerOptions1: {
        disabledDate(time) {
          let curDate = (new Date()).getTime();
          let three = 10 * 24 * 3600 * 1000;
          let threeMonths = curDate + three;
          return time.getTime() < Date.now() || time.getTime() > threeMonths;
        }
      },

      value1:''
    };
  },
  methods:{
    qingchu(){
      this.daterange = ''
    }
  },
  created(){
    const date = new Date()
    // console.log(date.getTime())
    console.log( 8.64e7,Date.now() - 8.64e7)
  }
};
</script>

<style></style>
